﻿using TallComponents.Web.Pdf;

namespace FolderStructureDemo.Treeview
{
   /// <summary>
   /// A node in a tree view.
   /// </summary>
   public abstract class TreeItem
   {
      /// <summary>
      /// Gets or sets the absolute path.
      /// </summary>
      /// <value>The absolute path.</value>
      public string AbsolutePath { get; set; }

      /// <summary>
      /// Gets the display name for the node.
      /// </summary>
      /// <value>The name.</value>
      public virtual string Name
      {
         get { return System.IO.Path.GetFileName( AbsolutePath ); }
      }
   }

   /// <summary>
   /// A directory node in a file tree view.
   /// </summary>
   public class DirectoryTreeItem : TreeItem
   {
      public string Path { get; set; }
   }

   /// <summary>
   /// A file node in a file tree view.
   /// </summary>
   public class PdfFileTreeItem : TreeItem
   {
      public Document Document { get; set; }
      public override string Name
      {
         get
         {
            var name = Document.DocumentInfo.Title;
            if( string.IsNullOrEmpty( name ))
            {
               name = System.IO.Path.GetFileName( AbsolutePath );
            }
            return name;
         }
      }

   }
}
